/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	         </p>
 * <p>创建者   :	heyong 
 * 
 * <p>描   述  :   农村公路建设    </p>
 * 
 * <p>最后修改 : $: 2017年6月27日-下午5:22:59 v 1.0.0	 win7   $ </p>
 * 
*/

package com.pengtu.gsj.controller.gcjs;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pengtu.gsj.controller.base.DefaultBaseController;
import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.entity.gcjs.NCRoadConstruction;
import com.pengtu.gsj.interceptor.Token;
import com.pengtu.gsj.service.gcjs.NCRoadConstructionService;

/**
 * 
 * NCRoadConstructionController
 * 
 * 2017年6月27日 下午5:22:59
 * 
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("nCRoadConstruction")
public class NCRoadConstructionController extends DefaultBaseController{
	@Autowired
	private NCRoadConstructionService nCRoadConstructionService;
	
	
	
	/**
	 * 加载
	 * @param id
	 * @return
	 */
	@ModelAttribute
	public NCRoadConstruction load(String id){
		NCRoadConstruction nCRoadConstruction;
		if(StringUtils.isNotEmpty(id)){
			nCRoadConstruction = nCRoadConstructionService.getNCRoadConstructionById(id);
		}else{
			nCRoadConstruction = new NCRoadConstruction();
		}
		return nCRoadConstruction;
	}
	
	
	/**
	 * 页面跳转
	 * @return
	 */
	@RequestMapping("listInfo")
	@Token(save = true)
	public String showLisfInfo() {
		return "gcjs/nCRoadConstruction_list";
	}
	
	
	@RequestMapping(value="list", produces = "application/json; charset=utf-8")
	@ResponseBody
	public Page<NCRoadConstruction> getRoadMaterialList(Page<NCRoadConstruction> page, HttpServletRequest request){
		QueryFilter queryFilter = QueryFilter.buildFromHttpRequest(request);
		if (!page.isOrderBySetted()) {
			page.setOrderBy("createDate");
			page.setOrder(Page.DESC);
		}
		page = nCRoadConstructionService.findNCRoadConstruction(page,queryFilter);
		return page;
	}
	
	/**
	 * 保存
	 * @param roadMaterial
	 * @return
	 */
	@RequestMapping(value = "save", method=RequestMethod.POST)
	@ResponseBody
	@Token(remove = true)
	public boolean saveNCRoadConstruction(@ModelAttribute NCRoadConstruction nCRoadConstruction){
		nCRoadConstructionService.saveNCRoadConstruction(nCRoadConstruction);
		return true;
	}
	
	
	/**
	 * 加载数据
	 * @param infoManagement
	 * @return
	 */
	@RequestMapping(value="show")
	@ResponseBody                                                     
	public NCRoadConstruction showNCRoadConstruction (@ModelAttribute NCRoadConstruction nCRoadConstruction){
		return nCRoadConstruction;
	}
	
	/**
	 * 删除
	 * @param infoManagement
	 * @return
	 */
	@RequestMapping(value="delete")
	@ResponseBody
	public boolean delateInfoManagement(@ModelAttribute NCRoadConstruction nCRoadConstruction){
		nCRoadConstructionService.delateNCRoadConstruction(nCRoadConstruction);
		return true;
	}
	
}
